#ifndef _GEO_SKEMODEL_H_
#define _GEO_SKEMODEL_H_

#include "LineManager.h"
#include "VertexManager.h"
#include "StrokeManager.h"
#include "SurfaceManager.h"
#include "CurveManager.h"

class CCamera;

class CSketchModel
{
public:
	CSketchModel(CCamera* pCamera);
	~CSketchModel();

	void Init();

	void SetCamera(CCamera* pCamera);

	CLineManager* GetLineManager() {return &m_lineManager;}
	CVertexManager* GetVertexManager() {return &m_vertexManager;}

	int GetVertexCount();
	int GetVertexCountWithoutInfPoint();
	CVertex* GetVertex(int index);

	int GetLineSegmentCount();
	CLineSegment GetLineSegment(int index);

	int GetScaffoldCount();
	CScaffold GetScaffold(int index);

	int GetSurfaceCount();
	CSurface GetSurface(int index);

	int GetCurveCount();
	CCurve GetCurve(int index);

	void SetStrokes(CStrokeManager strokeManager);

	CVertex InferPoint(CVertex2D p2D);
	CVertex InferActivePoint(CVertex2D p2D);
	bool InferScaffold();
	bool InferLine();
	bool InferCurve();
	bool InferSurface(int curveSegment);

	void UpdateVertices2D();

	CVertex2D FindNearestStrokeVertex(CVertex2D v);

	CVertex* GetActiveVertex();
	void SetActiveVertex(CVertex* vertex);

	//	file input and output
	bool LoadFromFile(const char* fileName);
	bool SaveIntoFile(const char* fileName);
protected:
	CVertex FindNearestVertex(CVertex2D p2D, CLineSegment l);
private:
	CCamera* m_pCamera;

	CLineManager m_lineManager;
	CVertexManager m_vertexManager;
	CSurfaceManager m_surfaceManager;
	CCurveManager m_curveManager;
	vector<CVertex2D> m_strokeVertices;

	CVertex* m_pActiveVertex;
};

#endif